﻿using FB.Data.Models;
using System;
using System.Collections.Generic;
using System.Security.Principal;

namespace FB.Membership.Principal
{
    [Serializable]
    public class FBIdentity : IIdentity
    //public class FBIdentity : System.Security.Claims.ClaimsIdentity
    {
        public Guid UserId { get; private set; }
        public string Name { get; private set; }
        public List<string> Services { get; set; }
        public dynamic OtherInfo { get; set; }
        public UserType UserType { get; set; }
        public bool NeedChangePW { get; set; }

        public  string AuthenticationType { get { return "FBFormsAuthentication"; } }
        public  bool IsAuthenticated { get { return !string.IsNullOrWhiteSpace(Name); } }

        public FBIdentity() { }
        public FBIdentity(FBIdentityCookieModel cookieModel)
        {
            Name = cookieModel.Name;
            UserId = cookieModel.UserId;
            Services = cookieModel.Services;
            OtherInfo = cookieModel.OtherInfo;
            UserType = cookieModel.UserType;
            NeedChangePW = cookieModel.NeedChangePW;
        }

    }

    
    public interface IIdentityCookieModel
    {
        Guid UserId { get; set; }
        string Name { get; set; }
        List<string> Services { get; set; }
        UserType UserType { get; set; }
        dynamic OtherInfo { get; set; }
        bool NeedChangePW { get; set; }
    }


    [Serializable]
    public class FBIdentityCookieModel : IIdentityCookieModel
    {
        public Guid UserId { get; set; }
        public string Name { get; set; }
        public UserType UserType { get; set; }
        public dynamic OtherInfo { get; set; }
        public List<string> Services { get; set; }
        public bool NeedChangePW { get; set; }

        public FBIdentityCookieModel() { }
    }
}
